<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/WEB-INF/templates/template.xhtml">
	<ui:define name="content">

		<h1>Cadastrar Sistema</h1><br />

		<h:form id="uploadForm" enctype="multipart/form-data" rendered="#{usuarioBean.logado and sistemaBean.liberaCadastro()}">
			
			<p:growl id="messages" showDetail="true" showSummary="true"/>
    
			<h:panelGrid columns="2" cellpadding="5" border="1">
			
				<h:outputText value="Nome do sistema " />
				<h:inputText value="#{sistemaBean.sistema.name}" id="systemName" required="true"/>
				
				<h:outputText value="Versão do sistema " />
				<h:inputText value="#{sistemaBean.sistema.version}" id="systemVersion" required="true"/>
				
				<h:outputText value="Arquivo " />
				<p:fileUpload value="#{sistemaBean.uploadedFile}" mode="simple" allowTypes="/(\.|\/)(csv)$/"/>

				<f:facet name="footer">
					<p:commandButton value="Salvar" ajax="false" actionListener="#{sistemaBean.salvar}" icon="ui-icon-disk" update=":uploadForm" onclick="load.show()" oncomplete="load.hide()"/>
					<p:panel visible="false" widgetVar="load">
						<p:graphicImage value="../img/ajaxloading.gif" />
						<h:outputText value=" Processando, aguarde ...."/>
					</p:panel>		
				</f:facet>
				
			</h:panelGrid>

		</h:form>
		
		<h:outputText value="É necessário ser administrador para realizar esta ação" rendered="#{!usuarioBean.logado}"/>

	</ui:define>
</ui:composition>
</html>